﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace QuanLiBongDa.DataAccessLayer
{
    class TranDauDAO
    {
        public static TranDauDAO CreateTranDauDAO()
        {
            return new TranDauDAO();
        }
        public bool Insert_TranDau(TranDauDTO t)
        {
            SqlParameter[]par=new SqlParameter[7];
            par[0] = new SqlParameter("@MaTD", t.MaTD);
            par[1] = new SqlParameter("@MaDN", t.MaDN);
            par[2] = new SqlParameter("@MaDK",t.MaDK);
            par[3] = new SqlParameter("@NgayDau",t.NgayDau);
            par[4] = new SqlParameter("@ThoiGian",t.ThoiGian);
            par[5] = new SqlParameter("@MaVong",t.MaVong);
            par[6] = new SqlParameter("@MaSan",t.MaSan);
            return SQLService.mmExecuteNonquery("Insert_TranDau", par);
        }
        public bool Update_TranDau(TranDauDTO t)
        {
            SqlParameter[] par = new SqlParameter[7];
            par[0] = new SqlParameter("@MaTD", t.MaTD);
            par[1] = new SqlParameter("@MaDN", t.MaDN);
            par[2] = new SqlParameter("@MaDK", t.MaDK);
            par[3] = new SqlParameter("@NgayDau", t.NgayDau);
            par[4] = new SqlParameter("@ThoiGian", t.ThoiGian);
            par[5] = new SqlParameter("@MaVong", t.MaVong);
            par[6] = new SqlParameter("@MaSan", t.MaSan);
            return SQLService.mmExecuteNonquery("Update_TranDau", par);
        }
        public bool Delete_TranDau(TranDauDTO t)
        {
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@MaTD",t.MaTD);
            return SQLService.mmExecuteNonquery("Delete_TranDau", par);
        }
        public void MaSan(ComboBox masan)
        {
            SqlDataReader dr = SQLService.mExecuteReader(SQLService.ReturnAll("SAN"));
            while (dr.Read())
                masan.Items.Add(dr["TenSan"]);
        }
        public void MaDoi(ComboBox madoi)
        {
            SqlDataReader dr = SQLService.mExecuteReader(SQLService.ReturnAll("DOIBONG"));
            while(dr.Read())
                madoi.Items.Add(dr["TenDoi"]);
        }
        public void MaVong(ComboBox mavong)
        {
            SqlDataReader dr = SQLService.mExecuteReader(SQLService.ReturnAll("VONGDAU"));
            while (dr.Read())
                mavong.Items.Add(dr["TenVong"]);
        }

    }
}
